//
//  HomeXQTableViewCell.m
//  geiTA
//
//  Created by duyan on 14-11-20.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "HomeXQTableViewCell.h"
#import "HomeXQkindmodel.h"
#import "UIImageView+WebCache.h"
@implementation HomeXQTableViewCell
- (void)dealloc
{
    [_lable release];
    [_image release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.image = [[UIImageView alloc]initWithFrame:CGRectZero];
        self.lable = [[UILabel alloc]initWithFrame:CGRectZero];
        [self  addObserver:self forKeyPath:@"model" options:NSKeyValueObservingOptionNew context:nil];
        [self addSubview:_image];
        [self addSubview:_lable];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    [self.image setFrame:CGRectMake(5, 5, self.contentView.frame.size.width - 10, self.contentView.frame.size.height - 10)];
    [self.lable setFrame:CGRectMake(5, self.contentView.frame.size.height - 40, self.contentView.frame.size.width - 10, 40)];
    [self.lable setTextColor:[UIColor whiteColor]];
    [self.lable setShadowColor:[UIColor blackColor]];
    self.lable.layer.backgroundColor = [UIColor blackColor].CGColor;
    self.lable.shadowOffset = CGSizeMake(0, -1.0);
    [self.lable setFont:[UIFont boldSystemFontOfSize:17]];
}
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([keyPath isEqualToString:@"model"]) {
        [self.image setImageWithURL:[NSURL URLWithString:self.model.cover_image_url]];
        [self.lable setText: self.model.title];
    }
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
